﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProductEdit.aspx.cs" Inherits="ZLCMS.Web.SystemManage.Basics.ProductSKU.ProductEdit"
    ValidateRequest="False" %>

<%@ Register TagPrefix="fc" TagName="FileControl" Src="~/SystemManage/Control/FileControl/FileControl.ascx " %>
<%@ Register TagPrefix="ddt" TagName="DropDownTreeControl" Src="~/SystemManage/Control/ddt/DropDownTreeControl.ascx " %>
<%@ Register Src="~/SystemManage/Control/SinglePictureControl.ascx" TagName="SinglePictureControl"
    TagPrefix="spc" %>
<%@ Register Src="/SystemManage/Control/CheckBoxControl/CheckBoxControl.ascx" TagName="CheckBoxControl"
    TagPrefix="uc1" %>
<form id="pageForm" method="post" runat="Server" class="pageForm required-validate"
onsubmit="return validateCallback(this, navTabAjaxDone);" action="/SystemManage/Basics/ProductSKU/ProductEdit.aspx">
<script type="text/javascript">
    $(function () {
        $('#<%= e_cbx_is_limit.ClientID  %>').change(function () {
            if ($(this).attr("checked")) {
                $('#e_dl_end_time').css("display", "block");
            }
            else {
                $('#e_dl_end_time').css("display", "none");
            }
        });
        $('#<%= e_ddl_product_kind.ClientID  %>').change(function () {
            if ($(this).val() != "shop") {
                $('#e_dl_rule_id').css("display", "block");
            }
            else {
                $('#e_dl_rule_id').css("display", "none");
            }
        });
        $("#cbk_user_tag").change(function () {
            var el = $(this);
            if (el.attr("checked")) {
                $("#fieldset_tag").fadeIn();
            }
            else {
                $("#fieldset_tag").fadeOut();
            }
        });
        $("input[name=eckbtag]").each(function () {

            $(this).change(function () {

                var ckbList = $("input[name=eckbtag]");
                var tids = '';
                for (var i = 0; i < ckbList.length; i++) {
                    if ($(ckbList[i]).attr("checked")) {
                        if (tids == '') {

                            tids += '_' + $(ckbList[i]).val() + '_';
                        }
                        else {
                            tids += $(ckbList[i]).val() + '_';
                        }
                    }
                }
                $('#<%= hid_tids.ClientID %>').val(tids);
            });

        });
        var tids = $('#<%= hid_tids.ClientID %>').val();
        tids = tids.substring(1, tids.length - 1); 
        var tidArray = tids.split("_");
        $(tidArray).each(function () {
            var tid = this;
            $("input[name=eckbtag]").each(function () {
                if (tid == $(this).val()) {
                    $(this).attr("checked", "checked");
                }
            });
        });

    });
</script>
<!-- 需保存的全局变量 -->
<asp:label runat="server" id="_id" visible="False"></asp:label>
<asp:hiddenfield runat="server" id="hid_tids"></asp:hiddenfield>
<div class="pageContent">
    <div class="pageFormContent" layouth="56">
        <dl class="nowrap">
            <dt>商品名称：</dt>
            <dd>
                <asp:textbox runat="server" id="tb_name" width="200px"></asp:textbox>
                （建议10个汉字以内）
            </dd>
        </dl>
        <dl class="nowrap">
            <dt>商品代码：</dt>
            <dd>
                <asp:textbox disabled="true" runat="server" id="tb_productno"></asp:textbox>
            </dd>
        </dl>
           <dl class="nowrap" >
            <dt>内部编码：</dt>
            <dd>
                <asp:textbox runat="server" id="tb_interior_code"></asp:textbox>
                
            </dd>
        </dl>
       <%-- 修改分类...plan B...修改分类时提醒确认操作...选择其他分类后生成SKU项目...并隐藏管理SKU产品 和重置SKU按钮...保存后管理SKU产品页面提示重置SKU产品...--%>
              <dl class="nowrap">
            <dt>商品分类：</dt>
            <dd>
                <ddt:DropDownTreeControl ID="ddl_producttype" runat="Server" class="required" DataFromUrl="/SystemManage/Control/ddt/TreeData_Category.aspx"
                    Kind="shop" />
                (点击放大镜选择分类)<br />
                <a  class="button" href="/SystemManage/Basics/ProductSKU/ModifyProductCategory.aspx?pno=<%= _productDB.ProductNo %>" target="ajaxTodo"  onclick="ChangeCategoryId(this)"
                title="修改分类后,产品原有定制属性和搜索属性将会改变!!!是否确定修改？"><span>修改分类</span></a>&nbsp;&nbsp;
                <font style="color:Red;">修改分类后并保存后,选择需要的SKU项目并保存后,再重置SKU产品</font>
                <br />
                 
                </dd>
        </dl>
           <dl  class="nowrap">
            <dt>所属部门：</dt>
            <dd>
                <asp:dropdownlist runat="server" id="ddl_dept"></asp:dropdownlist>
                 </dd>
        </dl>
        <fieldset>
            <legend>定制属性 : </legend>
            <div class="checklist">
                <dl class="nowrap">
                    <dt></dt>
                    <dd id="product_sku"   style="width:900px;" >
                        <asp:repeater runat="server" id="rp_skugroup">
                        <ItemTemplate>
                            <label for="ckb_sku_<%#Eval("Id") %>"><%#Eval("PrivateName")%><input id="ckb_sku_<%#Eval("Id") %>" type="checkbox" name="sku_group" <%# IsChecked(Eval("Id")) %> value="<%#Eval("Id")%>" /></label>
                        </ItemTemplate>
                </asp:repeater></dd>
                </dl>
                <dl>( 修改定制属性后,请保存后重置SKU )</dl>
                <dl class="nowrap">
                    <dt></dt>
                    <dd>
                    <a  class="button" href='/SystemManage/Basics/ProductSKU/ProductSKUBatchAdd.aspx?cid=<%= _productDB.TypeId %>&pno=<%= _productDB.ProductNo %>'
                target="dialog" width="750" height="500" rel="batchaddskuproduct" title="SKU产品管理"><span>SKU产品管理</span></a>
                
                <a  class="button" href="/SystemManage/Basics/ProductSKU/ProductSkuReset.aspx?pno=<%= _productDB.ProductNo %>" target="ajaxTodo"  onclick="return false;"
                title="是否要重置该产品SKU？"><span>重置SKU</span></a>
                    </dd>
                </dl>
            </div>
        </fieldset>
        <fieldset>
            <legend>分类搜索属性定制 : </legend>
            <div class="checklist" id="div_category_search_property">
                <asp:repeater runat="server" id="rpt_category_property" onitemdatabound="rpt_category_property_ItemDataBound">
                 <ItemTemplate>
                                <dl class="nowrap">
                                <dt><%# Eval("PropertyValue") %>：</dt>
                                <dd id="Dd2"   style="width:900px;" >
                                     <asp:repeater runat="server" id="rpt_category_property_item">
                                        <ItemTemplate>
                                           <label for="ckb_property_item_<%#Eval("Id") %>"><%#Eval("PropertyName")%><input id="ckb_property_item_<%#Eval("Id") %>" <%#IsSelect(Convert.ToInt32( Eval("Id"))) %> onclick="AddPropertyItem(this)" type="radio" name="property_<%# Eval("SearchPropertyId ")  %>" value="<%#Eval("Id")%>" /></label>
                                        </ItemTemplate>
                                        </asp:repeater>
                               </dd>
                            </dl>
                        </ItemTemplate>
                </asp:repeater>
            </div>
            <asp:hiddenfield runat="server" id="hid_property_item"></asp:hiddenfield>
        </fieldset>
        <%--    <dl class="nowrap">
            <dt>定制属性：</dt>
            <dd id="Dd1">
                <asp:repeater runat="server" ID="rp_skugroup">
                        <ItemTemplate>
                            <label for="ckb_sku_<%#Eval("Id") %>"><%#Eval("PrivateName")%><input id="Checkbox1" type="checkbox" name="sku_group" <%# IsChecked(Eval("Id")) %> value="<%#Eval("Id")%>" /></label>
                        </ItemTemplate>
                </asp:repeater>
            </dd>
        </dl>--%>
        <dl class="nowrap">
            <dt>简单描述：</dt>
            <dd>
                <asp:textbox runat="server" width="100%" id="tb_shortdesc"></asp:textbox>
            </dd>
        </dl>
         <dl class="nowrap">
            <dt>积分抵扣：</dt>
            <dd>
               <asp:textbox runat="server" width="100%" id="tb_score" class="required digits " min="0">0</asp:textbox>
            </dd>
        </dl>
        <dl>
            <dt>市场价格：</dt>
            <dd>
                <asp:textbox runat="server" class="number required" id="tb_mprice">0</asp:textbox>
                &nbsp;元&nbsp;
            </dd>
        </dl>
        <dl>
            <dt>销售价格：</dt>
            <dd>
                <asp:textbox runat="server" class="number required" id="tb_sprice">0</asp:textbox>
                &nbsp;元&nbsp;
            </dd>
        </dl>
        <dl>
            <dt>库存数量：</dt>
            <dd>
                <asp:textbox runat="server" class="digits required" min="0" id="tb_storage">0</asp:textbox>
            </dd>
        </dl><dl   class="nowrap"></dl>
          <dl  >
            <dt>产品类型：</dt>
            <dd>
                <asp:dropdownlist runat="server" id="e_ddl_product_kind"></asp:dropdownlist>
                 </dd>
        </dl>
        <dl  id="e_dl_rule_id" <%= _productDB.Kind=="shop"?"style='display:none;'":"" %> >
            <dt>配置编号：</dt>
            <dd>
                 <asp:textbox runat="server" class="digits" id="e_tb_rule_id" Text="0" ></asp:textbox>
                 </dd>
        </dl><dl   class="nowrap"></dl>
         <dl  >
            <dt>是否限时：</dt>
            <dd>
                <asp:checkbox runat="server" id="e_cbx_is_limit"></asp:checkbox>
                 </dd>
        </dl>
          <dl id="e_dl_end_time" <%= _productDB.IsLimitTime!="1"?"style='display:none;'":"" %>>
            <dt>结束时间：</dt>
            <dd>
                <asp:textbox runat="server" class="date" id="e_tb_end_time"  format="yyyy-MM-dd" name="tb_end_time"></asp:textbox><a class="inputDateButton" href="javascript:;">选择</a>
            </dd>
        </dl> <dl class="nowrap">
            <dt>是否可用优惠券：</dt>
            <dd>
                    <input id="ckb_available_coupon" type="checkbox" name="ckb_available_coupon"  runat="server"  />
                </dd>
        </dl>
        <dl class="nowrap">
            <dt>是否使用产品标签：</dt>
            <dd>
                    <input id="cbk_user_tag" type="checkbox" name="cbk_user_tag"  runat="server"  />
                </dd>
        </dl>
         
        <fieldset style=" float: left;width: 100%;<%= string.IsNullOrEmpty(_productDB.TagIds)?"display:none;":"" %>" id="fieldset_tag" >
            <legend>产品标签 : </legend>
            <div class="checklist"  >
                <dl class="nowrap"  >
                    <dd id="dd_tag"   style="width:100%;" >
                <asp:repeater runat="server" id="rpt_tag">
                    <ItemTemplate>
                        <label for="ckb_tag_<%#Eval("Id") %>"><%#Eval("TagName")%><input id="ckb_tag_<%#Eval("Id") %>" type="checkbox" name="eckbtag"  value="<%#Eval("Id")%>" /></label>
                    </ItemTemplate>
                </asp:repeater></dd>
                </dl>
                </div>
            </fieldset>
            
        <dl class="nowrap">
            <dt>商品大图：</dt>
            <dd>
                （将在列表页中显示。支持JPG、PNG格式，较好的效果为500*500）</dd>
        </dl>
        <dl class="nowrap">
            <dt>&nbsp;</dt>
            <dd>
                <spc:SinglePictureControl ID="fc_open" runat="server" ImageWidth="200" ImageHeight="200"
                    FileCountLimit="1" FileFilters="*.jpg;*.jpeg;*.bmp;*.png;*.gif" FileDesc="图片" />
            </dd>
        </dl>
        <dl class="nowrap">
            <dt>商品多图：</dt>
            <dd>
                （支持JPG、PNG格式，较好的效果为500*500）</dd>
        </dl>
        <dl class="nowrap">
            <dt>&nbsp;</dt>
            <dd>
                <fc:FileControl ID="fc_relatedimgs" runat="Server" MaxFiles="5" FileType="jpg|png|jpeg|gif"
                    AllowDelete="true" Enable="true" IsShowHistory="true" />
            </dd>
        </dl>
        <dl class="nowrap">
            <dt>商品介绍：</dt>
            <dd>
                <textarea class="editor" name="txtSummary" rows="10" cols="100" style="width: 100%"
                    id="txt_description" runat="Server" uplinkurl="/SystemManage/Common/ContentUpload.aspx?dir=doc&ext=zip,rar,txt"
                    uplinkext="zip,rar,txt" upimgurl="/SystemManage/Common/ContentUpload.aspx?dir=doc&ext=jpg,jpeg,gif,png"
                    upimgext="jpg,jpeg,gif,png" upflashurl="/SystemManage/Common/ContentUpload.aspx?dir=doc&ext=swf"
                    upflashext="swf" upmediaurl="/SystemManage/Common/ContentUpload.aspx?dir=doc&ext=avi"
                    upmediaext="avi">
            </textarea>
            </dd>
        </dl>
         <dl class="nowrap">
                <dt>详细参数：</dt>
                <dd>
                    <textarea class="editor" name="txtSummary" rows="10" cols="100" style="width: 100%"
                        id="txtParamContent" runat="Server" uplinkurl="/SystemManage/Common/ContentUpload.aspx?dir=doc&ext=zip,rar,txt"
                        uplinkext="zip,rar,txt" upimgurl="/SystemManage/Common/ContentUpload.aspx?dir=doc&ext=jpg,jpeg,gif,png"
                        upimgext="jpg,jpeg,gif,png" upflashurl="/SystemManage/Common/ContentUpload.aspx?dir=doc&ext=swf"
                        upflashext="swf" upmediaurl="/SystemManage/Common/ContentUpload.aspx?dir=doc&ext=avi"
                        upmediaext="avi">
            </textarea>
            </dd>
        </dl>
    </div>
    <div class="formBar">
        <ul>
              <% if (ZLCMS.Commands.User.Util.AuthUtil.CheckAuthorization("PRODUCT_MAN", "EDIT"))
                 { %>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit">
                            保存</button></div>
                </div>
            </li>
                <%} %>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            取消</button></div>
                </div>
            </li>
        </ul>
    </div>
</div>
<script type="text/javascript">
    function AddPropertyItem(ct) {
        var propertyItems = [];
        $("#div_category_search_property").find("input[type=radio]:checked").each(function () {
            propertyItems.push($(this).val());
        });
        $("#hid_property_item").val(propertyItems);
    }
    function ChangeCategoryId(ct) {
        $(ct).attr("href", '/SystemManage/Basics/ProductSKU/ModifyProductCategory.aspx?pno=<%= _productDB.ProductNo %>&cid=' + $('#ddl_producttype_inpNodeValue').val())
    }
</script>
</form>
